package com.qch.router;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

/**
 * @Author qch
 * @Date 2021/2/16
 * zookeeper操作类
 */
public class ZookeeperClients {
    private final CuratorFramework client;
    private static ZookeeperClients INSTANCE;
    static {
        RetryPolicy retryPolicy=new ExponentialBackoffRetry(1000,3);
        CuratorFramework client = CuratorFrameworkFactory.newClient("192.168.142.128:2181", retryPolicy);
        INSTANCE=new ZookeeperClients(client);
        client.start();
    }
    public ZookeeperClients(CuratorFramework client) {
        this.client = client;
    }
    public static CuratorFramework client(){
        return INSTANCE.client;
    }
}
